Component({
  behaviors: [],
  properties: {
    floorIndex: {
      type: Number,
      value: -1,
      observer: function (o) {
        o !== this.data.selectIndex &&
          this.setData({
            scrollTop: 0 === o ? "0rpx" : "".concat(80 * (o - 1), "rpx"),
            selectIndex: o,
            flag: !0,
          });
      },
    },
    floorList: {
      type: Array,
      value: [
        { name: "F7" },
        { name: "F6" },
        { name: "F5" },
        { name: "F4" },
        { name: "F3" },
        { name: "F2" },
        { name: "F1" },
        { name: "B1" },
        { name: "B2" },
        { name: "B3" },
      ],
      observer: function (o) {
        console.log(o, "floorList");
        var t = {
          floorList: o,
          floorControlHeight: this.calculateControlHeight(o),
          isHidden: 0 === o.length,
        };
        this.setData(t);
      },
    },
    scrollFlag: {
      type: Boolean,
      value: !0,
      observer: function (o) {
        o && this.scrollToFloor();
      },
    },
    buildingId: {
      type: String,
      observer: function (o) {
        0 === o || -1 === o
          ? this.setData({ isHidden: !0 })
          : this.setData({ isHidden: !1 });
      },
    },
    paddingBottom: { type: Number, value: 0 },
  },
  data: {
    floor: "",
    scrollTop: "0rpx",
    isHidden: !1,
    flag: !0,
    selectIndex: -1,
    floorControlHeight: 360,
  },
  lifetimes: { attached: function () {} },
  methods: {
    changeIndex: function (o) {
      var t = o.target.dataset.index,
        e = o.target.dataset.floor;
      this.setData({ floorIndex: t, selectIndex: t, floor: e, flag: !0 }),
        this.indoorFloorChange();
    },
    changeDownFloor: function () {
      if (this.data.floorIndex < this.data.floorList.length - 1) {
        var o = this.data.floorIndex + 1,
          t = this.data.floorList[o].name;
        this.setData({
          floorIndex: o,
          floor: t,
          scrollTop: this.getScrollTop(o) + "rpx",
          flag: !0,
        }),
          this.indoorFloorChange();
      }
    },
    changeUpFloor: function () {
      if (this.data.floorIndex > 0) {
        var o = this.data.floorIndex - 1,
          t = this.data.floorList[o].name;
        this.setData({
          floorIndex: o,
          floor: t,
          scrollTop: this.getScrollTop(o) + "rpx",
          flag: !0,
        }),
          this.indoorFloorChange();
      }
    },
    scrollToFloor: function () {
      var o = this,
        t = this.data.floorIndex;
      this.setData(
        { scrollTop: this.getScrollTop(t) - 1 + "rpx" },
        function () {
          o.setData({ scrollTop: o.getScrollTop(t) + "rpx" });
        },
      );
    },
    getScrollTop: function (o) {
      return 0 === o ? 0 : 80 * (o - 1);
    },
    calculateControlHeight: function (o) {
      var t = o.length;
      return t > 3 ? 360 : 3 === t ? 280 : t >= 2 ? 200 : 100;
    },
    indoorFloorChange: function () {
      this.triggerEvent("floorChange", {
        floor: this.data.floor,
        buildingId: this.data.buildingId,
      });
    },
  },
});
